package net.oschina.dajiangnan.tree;

import lombok.Data;

/**
 * 有分支的节点
 */
@Data
public abstract class CrossNode<T extends AbstractContext> extends AbstractNode<T> {

    protected abstract boolean crossLeft(T t);

    private Node leftNode;
    private Node rightNode;

    @Override
    public void processBusiness(T t) {
        return;
    }

    @Override
    public Node selectNode(T t) {
        if (crossLeft(t)) {
            return leftNode;
        } else {
            return rightNode;
        }
    }
}
